package cn.bb.controller;

import cn.bb.model.User;
import cn.bb.service.IUserService;
import com.github.pagehelper.Page;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import javax.jws.soap.SOAPBinding;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class UserController {
    @Resource
    private IUserService userService;
    @RequestMapping("/toList")
    public ModelAndView toList(){
        return new ModelAndView("list");
    }

    @RequestMapping("/getPage")
    public Map queryUser(int pageNum, int pageSize, User user){
        Map<String,Object> map = new HashMap<>();
        map.put("pageNum",pageNum);
        map.put("pageSize",pageSize);
        map.put("user",user);
        Page page = userService.queryLikeUsers(map);
        map.put("page",page);
        map.put("totalPage",page.getPages());
        return map;
    }

    public IUserService getUserService() {
        return userService;
    }

    public void setUserService(IUserService userService) {
        this.userService = userService;
    }
}
